<?php

require_once('utils.php');

if (!isset($_GET['industry']) || !property_exists($lang->home, $_GET['industry'])) 
	header('Location: tablet.php');

require_once('Mobile_Detect.php');
$detect = new Mobile_Detect();

$directory = $_SERVER["DOCUMENT_ROOT"]."/img/tablet/demos/".$_GET['industry']."/";
$images = glob($directory."*.jpg");
$slidesCount = count($images);
$currentSlide = isset($_GET['slide']) ? $_GET['slide'] : 1;
$currentSlideClass = "slide".$currentSlide;

?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title><?php printf("%s - %s", $lang->home->title, $lang->home->$_GET['industry']->h2) ?></title>
    <meta name="description" content="<?php echo($lang->home->description) ?>" />
    <meta property="fb:app_id" content="<?php echo($lang->home->fbapp_id) ?>" /> 
    <meta property="og:type" content="website" /> 
    <meta property="og:title" content="<?php echo($lang->home->ogtitle) ?>" /> 
   	<meta property="og:image" content="<?php echo(hostname().$lang->home->ogimage) ?>" /> 
	<meta property="og:description" content="<?php echo($lang->home->ogdescription) ?>" /> 
    <meta property="og:url" content="<?php echo(full_url()) ?>">
    
    <link rel="stylesheet" href="css/fonts/fonts.css" />
    <link rel="stylesheet" href="css/jquery.mobile.structure-1.0.1.min.css" />
    <link rel="stylesheet" href="css/tablet.css" />
</head>


<body>
    <div data-role="page" id="<?php echo($_GET['industry'].$currentSlide) ?>" class="demo" data-dom-cache="true">
        <div data-role="header">
            <h1><?php echo($lang->demos->$_GET['industry']->$currentSlideClass->h1) ?></h1>
            <a data-role="button" data-transition="pop reverse" href="industry.php?industry=<?php echo($_GET['industry']) ?>" class="close-demo ui-btn-right"></a>
        </div>
        <div data-role="content">
            <div class="demo-image">
                <?php
                $image = $images[$currentSlide-1];
                $image = str_replace($directory, "", $image); 
            	printf ('<img src="../img/tablet/demos/%s/%s" />', $_GET['industry'], $image);
				if ($currentSlide > 1)
				printf('<a class="prev" data-role="button" data-transition="slide reverse" href="?industry=%s&slide=%d" data-rel="page" data-prefetch>Prev</a>', $_GET['industry'], $currentSlide-1);
				
				if ($currentSlide == $slidesCount) {
					printf('<a href="includes/emailDialog.php" class="next" data-role="button" data-rel="dialog" data-inline="true" data-transition="fade">Next</a>');
				}
				else {
					printf('<a class="next" data-role="button" data-transition="slide" href="?industry=%s&slide=%d" data-rel="page" data-prefetch>Prev</a>', $_GET['industry'], $currentSlide+1);
				}
				
            	?>
            </div>
        </div>
        <div data-theme="" data-role="footer" data-fullscreen="true" id="footer">
        	<div class="copy">
        		<div class="counter"><?php printf ('%d/%d', $currentSlide, $slidesCount); ?></div>
                <span class="text"><?php echo($lang->demos->$_GET['industry']->$currentSlideClass->copy) ?></span>
                <a href="includes/emailDialog.php" class="button-email-demo" data-role="button" data-rel="dialog" data-inline="true" data-transition="fade"><?php echo($lang->buttons->emaildemo) ?></a>
            </div>
        	<div class="footer">
	            <div class="divider"></div>     
	            <div class="social">
	                <!-- AddThis Button BEGIN -->
	                <div class="addthis_toolbox addthis_default_style addthis_20x20_style">
	                <a class="addthis_button_email" addthis:title="<?php echo($lang->sharing->facebook->title) ?>" addthis:description="<?php echo($lang->sharing->facebook->description) ?>" addthis:email_template="discovermapsforbusiness"><img src="img/tablet/email.png" /></a>
	                <a class="addthis_button_twitter" addthis:title="<?php echo($lang->sharing->twitter) ?>"><img src="img/tablet/twitter.png" /></a>
	                </div>
	                <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4e5affd91537e09b"></script>
	                <!-- AddThis Button END -->
	                <div class="plusone"><div class="g-plusone" data-size="standard" data-href="<?php printf('%s/industry.php?industry=%s', hostname(), $_GET['industry']) ?>"></div>
	                    <!-- Place this render call where appropriate -->
	                    <script type="text/javascript">
	                      (function() {
	                        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
	                        po.src = 'https://apis.google.com/js/plusone.js';
	                        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
	                      })();
	                    </script>
	                </div>
	            </div>
	            <a data-role="button" data-transition="none" href="<?php $_SERVER["DOCUMENT_ROOT"] ?>/">
	                <img src="img/google-logo.png" alt="<?php echo($lang->home->footer->googlelogoalt) ?>" class="logo" />
	            </a>
	    	</div>
        </div>
    </div>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script>        window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>
    <script src="js/libs/raphael-min.js"></script>
    <script src="//www.google.com/jsapi"></script>
    <script src="js/plugins.js"></script>
    <script src="js/tablet.js"></script>
    <script src="js/libs/jquery.mobile-1.0.1.min.js"></script>
    <?php include_once($_SERVER['DOCUMENT_ROOT']."/includes/ga.php") ?>
</body>
</html>